﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;
using SES.CMS.BL;

namespace NhaBat.Module
{
    public partial class ucbanner : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dtHome = new DataView(new SlideBL().SelectByCategoryID(0), "", "OrderID ASC", DataViewRowState.CurrentRows).ToTable();
                rptSlide.DataSource = dtHome;
                if (dtHome.Rows.Count == 1) addHeaderOne();
                else addHeaderAll();
                rptSlide.DataBind();
            }
        }

        private void addHeaderOne()
        {
            HtmlHead head = Page.Header;

            LiteralControl lctl = new LiteralControl("<script type=\"text/javascript\" src=\"/js/previewOne.js\"></script>");

            head.Controls.Add(lctl);
        }

        private void addHeaderAll()
        {
            HtmlHead head = Page.Header;

            LiteralControl lctl = new LiteralControl("<script type=\"text/javascript\" src=\"/js/preview.js\"></script>");

            head.Controls.Add(lctl);
        }
    }
}